﻿
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace WinnerCMS.Data.Mapping
{
    public partial class CategoryMap
        : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<WinnerCMS.Model.Category>
    {
        public CategoryMap()
        {
            // table
            //ToTable("CMS_Categories");

            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();
            Property(t => t.ModelId)
                
                .IsRequired();
            Property(t => t.CategoryName)
                
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.CategoryNameEN)
                .IsUnicode(false)
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.ParentId)
                
                .IsOptional();
            Property(t => t.OrderId)
                
                .IsRequired();
            Property(t => t.LinkUrl)
                
                .HasMaxLength(300)
                .IsOptional();
            Property(t => t.Path)
                
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.DomainName)
                
                .HasMaxLength(255)
                .IsOptional();
            Property(t => t.FilePostfix)
                
                .HasMaxLength(10)
                .IsOptional();
            Property(t => t.FilePrefix)
                
                .HasMaxLength(10)
                .IsOptional();
            Property(t => t.UrlStyle)
                
                .IsRequired();
            Property(t => t.CategoryFilePostfix)
                
                .HasMaxLength(10)
                .IsOptional();
            Property(t => t.CategoryFilePrefix)
                
                .HasMaxLength(10)
                .IsOptional();
            Property(t => t.CategoryUrlStyle)
                
                .IsRequired();
            Property(t => t.CategoryIntro)
                
                .HasMaxLength(255)
                .IsOptional();
            Property(t => t.CategoryPic)
                
                .HasMaxLength(255)
                .IsOptional();
            Property(t => t.CategoryDescription)
                
                .HasMaxLength(500)
                .IsOptional();
            Property(t => t.CategoryKeyWord)
                
                .HasMaxLength(500)
                .IsOptional();
 
            Property(t => t.EnableContribute)
                
                .IsOptional();
            Property(t => t.EnableComment)
                
                .IsOptional();
 

            Property(t => t.TemplateFileName)
                
                .HasMaxLength(255)
                .IsOptional();
            Property(t => t.ShowPageTemplateFileName)
                
                .HasMaxLength(255)
                .IsOptional();
            Property(t => t.CategoryUrlFormat)
                .IsUnicode(false)
                .HasMaxLength(255)
                .IsOptional();
            Property(t => t.ContentUrlFormat)
                .IsUnicode(false)
                .HasMaxLength(255)
                .IsOptional();

            // Relationships
            HasRequired(t => t.Model)
                .WithMany(t => t.Categoryes)
                .HasForeignKey(d => d.ModelId);

            HasMany(t => t.Admins)
                .WithMany(t => t.CategoryForPermission);


            //InitializeMapping();
        }
    }
}

